import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testcase = "dbshop012-搜索商品"

firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"商品管理","管理商品")

# 1.选择商品名称，输入“美的”，
firefox.find_element_by_xpath('//input[@name="goods_name"]').send_keys("美的")
# 点击“搜索”按钮。
firefox.find_element_by_xpath('//i[@class="icon-search icon-white"]').click()
time.sleep(10)
# 2.搜索成功美的的后台商品
# 断言 商品数量不为0
s = firefox.find_element_by_xpath("//body").text
l = "商品数："
r = "\)"
num1 = reGetString(s,l,r)
print(num1)

if int(num1) > 0 :
    writeLog("%s 测试通过"%testcase)
else:
    writeLog("%s 测试失败" % testcase)
    getPhoto(firefox)
# firefox.quit()